<template>
  <div class="insuraceRecord">
    <el-form
      :model="thequery"
      ref="thequery"
      size="mini"
      :inline="true"
      style="margin: 0 0 20px 10px"
    >
      <el-form-item label="会员名称">
        <el-input v-model="thequery.userName"></el-input>
      </el-form-item>
      <el-form-item label="会员手机号">
        <el-input v-model="thequery.userAccount"></el-input>
      </el-form-item>
      <el-form-item label="保险生效日期">
        <el-date-picker
          type="date"
          v-model="thequery.reviewedTime"
          value-format="yyyy-MM-dd"
          placeholder="保险生效日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="保险失效日期">
        <el-date-picker
          type="date"
          v-model="thequery.reviewedTimeEnd"
          value-format="yyyy-MM-dd"
          placeholder="保险失效日期"
        >
        </el-date-picker>
      </el-form-item>

      <div style="display: flex; margin: 15px 0 0 0">
        <el-form-item label="保险名称">
          <el-select
            v-model="thequery.insuranceId"
            filterable
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="(item, index) in Insurancetype"
              :key="index"
              :label="item.insuranceName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="保单号" style="display: flex; margin: 0 20px 0 0">
          <el-input v-model="thequery.policyNumber"></el-input>
        </el-form-item>
        <el-form-item label="开保状态">
          <el-select
            v-model="thequery.insuranceStatus"
            filterable
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="(item, index) in opencoverstate"
              :key="index"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item style="margin: 0 20px 0 50px">
          <el-button type="primary" size="mini" @click="searchairPort"
            >查询</el-button
          >
        </el-form-item>
      </div>
    </el-form>

    <!-- 表格 -->
    <el-table
      :header-cell-style="{
        color: '#fff',
        background: '#6090EC',
        fontSize: '11px',
        fontWeight: 'normal',
        width: '100%',
      }"
      :data="auxiliary"
      size="mini"
      border
      stripe
      @selection-change="clickselect"
    >
      <el-table-column
        label="用户手机号"
        prop="userAccount"
        fixed
      ></el-table-column>
      <el-table-column label="用户名" prop="userName" fixed></el-table-column>
      <el-table-column
        label="保险名称"
        prop="insuranceName"
        fixed
      ></el-table-column>
      <el-table-column label="保险" prop="insuranceCode"></el-table-column>
      <el-table-column label="订单来源" prop="orderType">
        <template slot-scope="scope">
          <template v-if="scope.row.orderType == 'flight'">飞机票</template>
          <template v-if="scope.row.orderType == 'vipCard'">会员卡</template>
        </template>
      </el-table-column>
      <el-table-column label="订单id" prop="orderId"></el-table-column>
      <el-table-column label="保险类型" prop="insuranceType">
        <template slot-scope="scope">
          <template v-if="scope.row.insuranceType == 'ticket'">随票</template>
          <template v-if="scope.row.insuranceType == 'card'">随卡</template>
        </template>
      </el-table-column>
      <el-table-column label="保单号" prop="policyNumber"></el-table-column>
      <el-table-column label="保单文件地址" prop="policyFileUrl">
        <template slot-scope="scope">
          <span
            class="copyStyle"
            v-if="scope.row.insuranceStatus != 'failure'"
            @click="copyPolicyFileUrl(scope.row.policyFileUrl)"
            >复制</span
          >
        </template>
      </el-table-column>
      <el-table-column label="被保人姓名" prop="insuredName"></el-table-column>
      <el-table-column
        label="被保人证件号"
        prop="insuredIdNumber"
      ></el-table-column>
      <el-table-column
        label="被保人证件类型"
        prop="insuredPhone"
      ></el-table-column>
      <el-table-column
        label="被保人手机号"
        prop="insuredPhone"
      ></el-table-column>
      <el-table-column
        label="被保人生日"
        prop="insuredBirthday"
      ></el-table-column>
      <el-table-column label="开保状态" prop="insuranceStatus">
        <template slot-scope="scope">
          <template v-if="scope.row.insuranceStatus == 'success'"
            >开保成功</template
          >
          <template v-if="scope.row.insuranceStatus == 'failure'"
            >开保失败</template
          >
           <template v-if="scope.row.insuranceStatus == 'refund'"
            >退保成功</template
          >
           <template v-if="scope.row.insuranceStatus == 'refundFailure'"
            >退保失败</template
          >
        </template>
      </el-table-column>
      <el-table-column label="投保日期" prop="insureTime"></el-table-column>
      <el-table-column label="生效日期" prop="effectiveDate"></el-table-column>
      <el-table-column label="失效日期" prop="failureDate"></el-table-column>
      <el-table-column label="备注" prop="insuranceRemark"></el-table-column>

      <el-table-column label="操作" prop="employee" width="360" fixed="right">
        <template slot-scope="scope">
          <el-button
            v-if="
              scope.row.insuranceStatus != 'refund' &&
              scope.row.insuranceStatus != 'success'
            "
            type="primary"
            @click="dealwithorder(scope.row)"
            size="mini"
            >修改</el-button
          >
          <el-button
            type="primary"
            v-if="scope.row.insuranceStatus == 'failure'"
            size="mini"
            @click="opencover(scope.row)"
            >重新开保</el-button
          >

          <el-button
            type="primary"
            @click="querystate(scope.row)"
            v-if="scope.row.insuranceStatus == 'success'"
            size="mini"
            >查询开保日志</el-button
          >

          <el-button
            v-if="scope.row.insuranceStatus == 'success'"
            type="primary"
            slot="reference"
            @click="surrender(scope.row)"
            size="mini"
            >退保</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 15, 20]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageTotal"
    >
    </el-pagination>
    <!-- 修改弹窗 -->
    <el-dialog
      title="修改会员开保信息"
      :visible.sync="ModifydialogVisible"
      :close-on-click-modal="false"
      width="50%"
    >
      <el-form
        :model="ruleForm"
        :rules="Modifrules"
        inline
        ref="ruleForm"
        label-width="100px"
        size="mini"
      >
        <el-form-item label="会员手机号" prop="userAccount">
          <el-input v-model="ruleForm.userAccount"></el-input>
        </el-form-item>
        <el-form-item label="会员姓名" prop="userName">
          <el-input v-model="ruleForm.userName"></el-input>
        </el-form-item>
        <el-form-item label="出生日期" prop="insuredBirthday">
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="ruleForm.insuredBirthday"
            type="date"
            placeholder="选择出生日期"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="证件类型" prop="insuredIdType">
          <el-select
            v-model="ruleForm.insuredIdType"
            placeholder="请选择证件类型"
            clearable
          >
            <el-option
              v-for="item in mold"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="证件号" prop="insuredIdNumber">
          <el-input v-model="ruleForm.insuredIdNumber"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="insuredPhone">
          <el-input v-model="ruleForm.insuredPhone"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')"
            >保存</el-button
          >
          <el-button @click="ModifydialogVisible = false">关闭</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 查看开保日志信息 -->
    <el-dialog
      title="查看会员开保信息"
      :visible.sync="viewdialogVisible"
      width="50%"
    >
      <el-descriptions>
        <el-descriptions-item label="会员姓名">{{
          Seelog.userName
        }}</el-descriptions-item>
        <el-descriptions-item label="会员手机号">{{
          Seelog.userAccount
        }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions>
        <el-descriptions-item label="保险名称">{{
          Seelog.insuranceName
        }}</el-descriptions-item>
        <el-descriptions-item label="保险">{{
          Seelog.insuranceCode
        }}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="订单来源">{{
          Seelog.orderType == "flight" ? "飞机票" : "会员卡"
        }}</el-descriptions-item>
        <el-descriptions-item label="订单id">{{
          Seelog.orderId
        }}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="保险类型">{{
          Seelog.insuranceType == "card" ? "随卡" : "随票"
        }}</el-descriptions-item>
        <el-descriptions-item label="保单号">{{
          Seelog.policyNumber
        }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions>
        <el-descriptions-item label="被保人姓名">{{
          Seelog.insuredName
        }}</el-descriptions-item>
        <el-descriptions-item label="被保人证件类型">{{
          Seelog.insuredIdType == "BIRTH"
            ? "出生证明"
            : Seelog.insuredIdType == "HKB"
            ? "户口本"
            : Seelog.insuredIdType == "HKAMP"
            ? "港澳通行证"
            : Seelog.insuredIdType == "GAJMLWNDTXZ"
            ? "港澳居民来往内地通行证"
            : Seelog.insuredIdType == "HZ"
            ? "护照"
            : Seelog.insuredIdType == "MILITARY"
            ? "军人证"
            : Seelog.insuredIdType == "ZGJMSFZ"
            ? "身份证"
            : ""
        }}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="被保人证件号">{{
          Seelog.insuredIdNumber
        }}</el-descriptions-item>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="被保人手机号">{{
          Seelog.insuredPhone
        }}</el-descriptions-item>

        <el-descriptions-item label="被保人生日">{{
          Seelog.insuredBirthday
        }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions>
        <el-descriptions-item label="开保状态">{{
          Seelog.insuranceStatus == "success"
            ? "开保成功"
            : Seelog.insuranceStatus == "failure"
            ? "开保失败"
            : Seelog.insuranceStatus == "refund"
            ? "退保"
            : ""
        }}</el-descriptions-item>

        <el-descriptions-item label="投保日期">{{
          Seelog.insureTime
        }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions>
        <el-descriptions-item label="生效日期">{{
          Seelog.effectiveDate
        }}</el-descriptions-item>
        <el-descriptions-item label="生效日期">{{
          Seelog.effectiveDate
        }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions>
        <el-descriptions-item label="备注">{{
          Seelog.insuranceRemark
        }}</el-descriptions-item>
      </el-descriptions>

      <div style="margin: 10px 0 0 45%">
        <el-button @click="viewdialogVisible = false">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 重新开保 -->
    <el-dialog
      title="会员重新开保"
      :visible.sync="Openagainconfirmed"
      :close-on-click-modal="false"
      width="30%"
      center
    >
      <span>确认重新开保吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="Openagainconfirmed = false">取 消</el-button>
        <el-button type="primary" @click="againconfirmedOpen()"
          >确 定</el-button
        >
      </span>
      <!-- <el-form
        :model="Opentheinsurance"
        :rules="ModifrulesOpen"
        ref="Opentheinsurance"
        label-width="192px"
        size="mini"
        :inline="true"
      >
        <el-form-item label="投保类型" prop="type">
          <el-select v-model="Opentheinsurance.type" clearable>
            <el-option value="HeyDay" label="鼎盛"></el-option>
            <el-option value="Dove" label="德付通"></el-option>
            <el-option value="HangLian" label="航联"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单号" prop="orderNum">
          <el-input v-model="Opentheinsurance.orderNum"></el-input>
        </el-form-item>
        <el-form-item label="支付渠道" prop="paymentChannel">
          <el-select v-model="Opentheinsurance.paymentChannel" clearable>
            <el-option value="微信">微信</el-option>
            <el-option value="银行卡借记卡">银行卡借记卡</el-option>
            <el-option value="银行信用卡">银行信用卡</el-option>
            <el-option value="电话语音支付">电话语音支付</el-option>
            <el-option value="总办赠卡支付">总办赠卡支付</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="保险业务来源" prop="orderSource">
          <el-select
            v-model="Opentheinsurance.orderSource"
            clearable
            placeholder="请选择证件类型"
          >
            <el-option
              v-for="(item, index) in insurance"
              :key="index"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="航班/列车号" prop="flightNo">
          <el-input v-model="Opentheinsurance.flightNo"></el-input>
        </el-form-item>
        <el-form-item
          label="航班/列车时间"
          prop="flightDate"
          v-if="Opentheinsurance.type != 'HeyDay'"
        >
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="Opentheinsurance.flightDate"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="航班起飞/列车出发时间"
          prop="flightTime"
          v-if="Opentheinsurance.type != 'HeyDay'"
        >
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm"
            v-model="Opentheinsurance.flightTime"
            type="datetime"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="航班到达/列车到达时间"
          prop="arriveTime"
          v-if="Opentheinsurance.type != 'HangLian'"
        >
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm"
            v-model="Opentheinsurance.arriveTime"
            type="datetime"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="被保人姓名"
          prop="insuredName"
          v-if="
            Opentheinsurance.type == 'Dove' || Opentheinsurance.relation != '01'
          "
        >
          <el-input v-model="Opentheinsurance.insuredName"></el-input>
        </el-form-item>
        <el-form-item
          label="被保人证件类型"
          prop="insuredIdType"
          v-if="
            Opentheinsurance.type == 'Dove' || Opentheinsurance.relation != '01'
          "
        >
          <el-select
            v-model="Opentheinsurance.insuredIdType"
            placeholder="请选择证件类型"
            clearable
          >
            <el-option
              v-for="(item, index) in mold"
              :key="index"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="被保人证件号"
          prop="insuredId"
          v-if="
            Opentheinsurance.type == 'Dove' || Opentheinsurance.relation != '01'
          "
        >
          <el-input v-model="Opentheinsurance.insuredId"></el-input>
        </el-form-item>
        <el-form-item
          label="被保人联系电话"
          prop="insuredPhone"
          v-if="
            Opentheinsurance.type == 'Dove' || Opentheinsurance.relation != '01'
          "
        >
          <el-input v-model="Opentheinsurance.insuredPhone"></el-input>
        </el-form-item>
        <el-form-item
          label="保险开始日期"
          prop="insuranceStartDate"
          v-if="Opentheinsurance.type == 'HangLian'"
        >
          <el-input v-model="Opentheinsurance.insuranceStartDate"></el-input>
        </el-form-item>
        <el-form-item
          label="电子保单号"
          prop="cardNum"
          v-if="Opentheinsurance.type == 'HangLian'"
        >
          <el-input v-model="Opentheinsurance.cardNum"></el-input>
        </el-form-item>
        <el-form-item
          label="被保人生日"
          prop="beInsuredBirthday"
          v-if="Opentheinsurance.type == 'Dove'"
        >
          <el-input v-model="Opentheinsurance.beInsuredBirthday"></el-input>
        </el-form-item>
        <el-form-item
          label="被保人票号"
          prop="ticketNo"
          v-if="Opentheinsurance.type == 'Dove'"
        >
          <el-input v-model="Opentheinsurance.ticketNo"></el-input>
        </el-form-item>
        <el-form-item
          label="票号所对应航班号"
          prop="flightIndex"
          v-if="Opentheinsurance.type == 'Dove'"
        >
          <el-input v-model="Opentheinsurance.flightIndex"></el-input>
        </el-form-item>
        <el-form-item
          label="出发城市三字码"
          prop="depCity"
          v-if="Opentheinsurance.type == 'Dove'"
        >
          <el-input v-model="Opentheinsurance.depCity"></el-input>
        </el-form-item>
        <el-form-item
          label="到达城市三字码"
          prop="arrCity"
          v-if="Opentheinsurance.type == 'Dove'"
        >
          <el-input v-model="Opentheinsurance.arrCity"></el-input>
        </el-form-item>
        <el-form-item
          label="保险产品类型"
          prop="insuranceType"
          v-if="Opentheinsurance.type == 'Dove'"
        >
          <el-input v-model="Opentheinsurance.insuranceType"></el-input>
        </el-form-item>
        <el-form-item
          label="与会员关系"
          prop="relation"
          v-if="Opentheinsurance.type == 'HeyDay'"
        >
          <el-select
            v-model="Opentheinsurance.relation"
            placeholder="请选择证件类型"
            clearable
          >
            <el-option value="01" label="本人"></el-option>
            <el-option value="02" label="父母"></el-option>
            <el-option value="03" label="子女"></el-option>
            <el-option value="04" label="配偶"></el-option>
            <el-option value="05" label="亲属"></el-option>
            <el-option value="06" label="雇佣关系"></el-option>
            <el-option value="07" label="其他"></el-option>
            <el-option value="08" label="兄弟"></el-option>
            <el-option value="09" label="姐妹"></el-option>
            <el-option value="10" label="法人"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="出发地"
          prop="startPosition"
          v-if="Opentheinsurance.type == 'HeyDay'"
        >
          <el-input v-model="Opentheinsurance.startPosition"></el-input>
        </el-form-item>
        <el-form-item
          label="目的地"
          prop="destination"
          v-if="Opentheinsurance.type == 'HeyDay'"
        >
          <el-input v-model="Opentheinsurance.destination"></el-input>
        </el-form-item>
        <el-form-item
          label="投保人邮箱"
          prop="phEmail"
          v-if="Opentheinsurance.type == 'HeyDay'"
        >
          <el-input v-model="Opentheinsurance.phEmail"></el-input>
        </el-form-item>
        <el-form-item
          label="被保人邮箱"
          prop="email"
          v-if="Opentheinsurance.type == 'HeyDay'"
        >
          <el-input v-model="Opentheinsurance.phEmail"></el-input>
        </el-form-item>
        <el-form-item
          label="性别"
          prop="sex"
          v-if="Opentheinsurance.type == 'Dove'"
        >
          <el-select clearable v-model="ruleForm.sex" placeholder="请选择性别">
            <el-option label="男" value="male"></el-option>
            <el-option label="女" value="female"></el-option>
          </el-select>
        </el-form-item>
        <div style="text-align: center">
          <el-form-item>
            <el-button
              type="primary"
              @click="againconfirmedOpen('Opentheinsurance')"
              >保存</el-button
            >
            <el-button @click="Openagainconfirmed = false">关闭</el-button>
          </el-form-item>
        </div>
      </el-form> -->
    </el-dialog>
    <!-- 退保 -->
    <el-dialog
      title="会员退保"
      :visible.sync="OpenagainconfirmedReturn"
      :close-on-click-modal="false"
      width="30%"
      center
    >
      <span>确认退保吗？</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="OpenagainconfirmedReturn = false">取 消</el-button>
        <el-button type="primary" @click="firmedReturn()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "insuraceRecord",
  data() {
    return {
      // 重新开保表单入参
      Opentheinsurance: {},
      // 重新开保
      Openagainconfirmed: false,
      // 退保
      OpenagainconfirmedReturn: false,
      // 日志日志
      Seelog: {},
      // 保险业务线
      insurance: [
        {
          value: "flight",
          label: "机票",
        },
        {
          value: "hotel",
          label: "酒店",
        },
        {
          value: "train",
          label: "火车票",
        },
        {
          value: "ID_CARD",
          label: "身份证",
        },
        {
          value: "ID_CARD",
          label: "身份证",
        },
      ],
      // 支付类型
      paymentChannel: [
        {
          value: "flight",
          label: "微信",
        },
        {
          value: "flight",
          label: "支付宝",
        },
        {
          value: "flight",
          label: "银联二维码支付",
        },
        {
          value: "银联",
          label: "机票",
        },
        {
          value: "flight",
          label: "机票",
        },
        {
          value: "flight",
          label: "机票",
        },
        {
          value: "flight",
          label: "机票",
        },
        {
          value: "flight",
          label: "机票",
        },
        {
          value: "flight",
          label: "机票",
        },
      ],
      // 证件类型
      mold: [
        {
          value: "ZGJMSFZ",
          label: "身份证",
        },
        {
          value: "MILITARY",
          label: "军人证",
        },
        {
          value: "HZ",
          label: "护照",
        },
        {
          value: "GAJMLWNDTXZ",
          label: "港澳居民来往内地通行证",
        },
        {
          value: "GATJMJZZ",
          label: "港澳台居民居住证",
        },
        {
          value: "TWJMLWDLTXZ",
          label: "台湾居民来往大陆通行证",
        },
        {
          value: "WGRYJJLSFZ",
          label: "外国人永久居留身份证",
        },
        {
          value: "HKAMP",
          label: "港澳通行证",
        },
        {
          value: "HKB",
          label: "户口本",
        },
        {
          value: "BIRTH",
          label: "出生证明",
        },
      ],
      // 保险公司
      insurancecompanyListList: [],
      // 开保状态
      opencoverstate: [
        {
          value: "success",
          label: "开保成功",
        },
        {
          value: "failure",
          label: "开保失败",
        },
        {
          value: "refund",
          label: "退保",
        },
      ],
      // 保险类型列表
      Insurancetype: [],

      tabDtata: [],
      viewdialogVisible: false,
      // 修改表单验证
      Modifrules: {
        insuredBirthday: [
          {
            required: true,
            message: "请选择证件类型",
            trigger: "change",
          },
        ],
        insuredIdType: [
          {
            required: true,
            message: "请选择证件类型",
            trigger: "change",
          },
        ],
        insuredIdNumber: [
          {
            required: true,
            message: "请输入证件号",
            trigger: "blur",
          },
        ],

        insuredName: [
          {
            required: true,
            message: "请输入证件号",
            trigger: "blur",
          },
        ],

        insuredPhone: [
          {
            required: true,
            message: "请输入证件号",
            trigger: "blur",
          },
        ],
      },
      // 修改表单
      ruleForm: {
        userAccount: "",
        userName: "",
        insuredBirthday: "",
        insuredIdNumber: "",
        insuredIdType: "",
        insuredName: "",
        insuredPhone: "",
      },
      ModifydialogVisible: false,
      // 分页
      pageSize: 10,
      currentPage: 1,
      pageTotal: 0,
      // 表格点击时间
      clickselectList: [],
      // 查询条件
      thequery: {
        // // 开始时间
        // reviewedTime: new Date(new Date() - 24 * 60 * 60 * 1000 * 7)
        //   .toLocaleDateString()
        //   .replace(/\//g, "-"),
        // // 结束时间
        // reviewedTimeEnd: new Date(new Date())
        //   .toLocaleDateString()
        //   .replace(/\//g, "-"),
         // 开始时间
        reviewedTime:null,
        // 结束时间
        reviewedTimeEnd:null,
        insuranceId: null,
        policyNumber: null,
        insuranceStatus: null,
        userName: null,
        userAccount: null,
        pageNo: 1,
        pageSize: 10,
      },
      // 表格数据
      auxiliary: [],
      // 开保状态
      querySearch: [],
      // 重新开保id
      reinsuranceId: null,
      // 退保
      returnFirmedId: null,
    };
  },
  methods: {
    // 复制链接
    copyPolicyFileUrl(val) {
      console.log(val);
      this.$copyText(val).then((e) => {
        this.$message({
          message: "复制成功",
          type: "success",
        });
      });
    },

    // 修改会员信息
    getupGuarantee() {
      this.$axios
        .getupGuarantee({
          id: this.ruleForm.id,
          userAccount: this.ruleForm.userAccount,
          userName: this.ruleForm.userName,
          insuredBirthday: this.ruleForm.insuredBirthday,
          insuredIdNumber: this.ruleForm.insuredIdNumber,
          insuredIdType: this.ruleForm.insuredIdType,
          insuredName: this.ruleForm.insuredName,
          insuredPhone: this.ruleForm.insuredPhone,
        })
        .then((res) => {
          console.log(res);
          if (res.code == "00000") {
            this.$message({
              message: "修改成功",
              type: "success",
            });
            this.ModifydialogVisible = false;
            this.getguaranteeList();
          } else {
            this.$message({
              message: "修改失败，请核对信息重新修改",
              type: "warning",
            });
          }
        });
    },
    // 列表数据
    getguaranteeList() {
      this.$axios
        .getInsuranceRecordList({
          insuranceId: this.thequery.insuranceId,
          policyNumber: this.thequery.policyNumber,
          insuranceStatus: this.thequery.insuranceStatus,
          minInsureTime: this.thequery.reviewedTime,
          maxInsureTime: this.thequery.reviewedTimeEnd,
          userName: this.thequery.userName,
          userAccount: this.thequery.userAccount,
          pageNo: this.thequery.pageNo,
          pageSize: this.thequery.pageSize,
        })
        .then((res) => {
          console.log(res);
          if (res.code == "00000") {
            this.auxiliary = res.data.records;
            this.pageTotal = res.data.total;
          }
        });
    },
    // 查询待修改接口
    getgetInsuranceRecord(id) {
      this.$axios
        .getgetInsuranceRecord({
          id: id,
        })
        .then((res) => {
          console.log(res);
          this.ruleForm = res.data;
          this.Opentheinsurance = res.data;
        });
    },
    // 查询按钮
    searchairPort() {
      this.thequery.pageNo = 1;
      this.thequery.pageSize = 10;
      this.getguaranteeList();
    },
    // 开保按钮
    opencover(row) {
      console.log(row);
      this.reinsuranceId = row.id;
      // this.getgetInsuranceRecord(row.insRecordId);
      this.Openagainconfirmed = true;
    },
    // 修改开保按钮
    dealwithorder(row) {
      console.log(row);
      this.ModifydialogVisible = true;
      this.getgetInsuranceRecord(row.id);
    },
    // 修改保存按钮
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.getupGuarantee();
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 重新开保确认按钮
    againconfirmedOpen() {
      this.$axios
        .getreinsurance({
          id: this.reinsuranceId,
        })
        .then((res) => {
          if (res.code == "00000") {
            if (res.data) {
              this.$message({
                message: "重新开保成功",
                type: "success",
              });
              this.Openagainconfirmed = !this.Openagainconfirmed;
            } else {
              this.$message({
                message: "重新开保失败，请仔细修改信息",
                type: "error",
              });
            }
          } else {
          }
        });
    },
    // 退保
    firmedReturn() {
      this.$axios
        .refundHLInsurance({
          id: this.returnFirmedId,
        })
        .then((res) => {
          if (res.code == "00000") {
            this.OpenagainconfirmedReturn = !this.OpenagainconfirmedReturn;

            if (res.data) {
              this.$message({
                message: "退保成功",
                type: "success",
              });
            } else {
              this.$message({
                message: "退保失败",
                type: "error",
              });
            }
          } else {
          }
        });
    },

    // 表格查询保单开保日志按钮
    querystate(row) {
      console.log(row);
      this.$axios
        .getgetInsuranceRecord({
          id: row.id,
        })
        .then((res) => {
          console.log(res);
          if (res.code == "00000") {
            this.Seelog = res.data;
            this.viewdialogVisible = true;
          }
        });
    },

    // 表格退保按钮
    surrender(row) {
      this.returnFirmedId = row.id;
      this.OpenagainconfirmedReturn = !this.OpenagainconfirmedReturn;
    },
    // 表格点击事件
    clickselect(row) {
      console.log(row);
      this.clickselectList = row;
      console.log(this.clickselectList);
    },
    // 保险类型
    getinsuranceTypeList() {
      this.$axios.getInsuranceList().then((res) => {
        if (res.code == "00000") {
          this.Insurancetype = res.data;
        }
      });
    },
    // 保险公司
    getinsuranceCompanyList() {
      this.$axios.getinsuranceCompanyList({}).then((res) => {
        console.log(res);
        if (res.code == "200") {
          this.insurancecompanyListList = res.data;
        }
      });
    },
    // 分页
    handleSizeChange(value) {
      this.thequery.pageSize = value;

      this.getguaranteeList();
    },
    handleCurrentChange(value) {
      this.thequery.pageNo = value;
      this.getguaranteeList();
    },
  },
  mounted() {
    // 保险类型
    this.getinsuranceTypeList();
    // 保险公司
    this.getinsuranceCompanyList();
    // 列表数据
    this.getguaranteeList();
  },
};
</script>

<style scoped>
.insuraceRecord {
  margin: 20px;
}
.copyStyle {
  color: #6090ec;
  cursor: pointer;
}
</style>